package org.client.view.manage;

import java.net.*;
import java.io.*;
import org.client.tools.Mdd;
import org.pojo.MessageType;
import org.pojo.User;
import org.pojo.Message.Message;
public class IMRegisterClientConServer {
	public  Socket s;
	//发送注册请求
	public boolean sendRegisterInfoToServer(User reguser){
		
		boolean b=false;
			try {
				System.out.println("RegisterConnectServer,please wait...");
				s=new Socket("127.0.0.1",10000);
				ObjectOutputStream oos=new ObjectOutputStream(s.getOutputStream());
				Message mr= new Message();
				mr.setMesType(MessageType.message_register);//请求注册
				reguser.setPassword(Mdd.MD5(reguser.getPassword()));
				mr.setCon(reguser);
				oos.writeObject(mr);
				ObjectInputStream ois=new ObjectInputStream(s.getInputStream());
				Message msr=(Message)ois.readObject();
				//这里就是验证用户注册的地方		
				if(msr.getMesType().equals(MessageType.message_succeed)){
					b = true;
				}
				//关闭Scoket
				oos.close();
				ois.close();
				s.close();		
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}			
		return b;
	}
}
